﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Booking_Hotel.DBML;

namespace Booking_Hotel.DAL
{
    public class Supplier_RoomDAO
    {
        ThanhBHotelDataContext tbk = new ThanhBHotelDataContext();

        public Supplier_Hotel_Room GetSupplier_Hotel_RoomByID(int ID)
        {
            return tbk.sp_Supplier_Hotel_RoomSelect(ID).SingleOrDefault();
        }

        public void addSupplier_Hotel_Room(Supplier_Hotel_Room shr)
        {
            Supplier_Hotel_Room add = new Supplier_Hotel_Room
            {
                Supplier_Hotel_LoaiPhongID = shr.Supplier_Hotel_LoaiPhongID,
                TenPhong = shr.TenPhong,
                SoGiuong = shr.SoGiuong,
                SoNguoiLon = shr.SoNguoiLon,
                SoTreEm = shr.SoTreEm,
                Description = shr.Description,
                TrangThaiLoaiPhong = shr.TrangThaiLoaiPhong
            };
            tbk.Supplier_Hotel_Rooms.InsertOnSubmit(add);
            tbk.SubmitChanges();
        }

        public void updateSupplier_Hotel_Room(Supplier_Hotel_Room shr)
        {
            Supplier_Hotel_Room update = tbk.Supplier_Hotel_Rooms.Single(ca => ca.Supplier_Hotel_RoomID == (int)shr.Supplier_Hotel_RoomID);
            {
                update.Supplier_Hotel_RoomID = shr.Supplier_Hotel_RoomID;
                update.Supplier_Hotel_LoaiPhongID = shr.Supplier_Hotel_LoaiPhongID;
                update.TenPhong = shr.TenPhong;
                update.SoGiuong = shr.SoGiuong;
                update.SoNguoiLon = shr.SoNguoiLon;
                update.SoTreEm = shr.SoTreEm;
                update.Description = shr.Description;
                update.TrangThaiLoaiPhong = shr.TrangThaiLoaiPhong;
            }
            tbk.SubmitChanges();
        }
    }
}